home *** CD-ROM | disk | FTP | other *** search
/ DarkBASIC - The Ultimate 3D Game Creator / PCactive 8 CD1 - DarkBasic.iso / SOFTWARE / DEMOS / Technology demos / can / can.dba < prev    next >
Encoding:
Text File  |  2001-01-25  |  3.4 KB  |  92 lines

  1. remstart
  2.             *-----------------------------------------------*
  3.             |                                               |
  4.             |     Pepsi Can Technology Demo                 |
  5.             |     Version 1.01 - 25th January 2001          |
  6.             |                                               |
  7.             |     Author:  Rob Moran (theGecko)             |
  8.             |     Web:     http://www.gecko.f2s.com        |
  9.             |     E-Mail:  gecko@f2s.com                    |
  10.             |     AIM:     Rob M0RAN                        |
  11.             |     ICQ#:    105558276                        |
  12.             |                                               |
  13.             |     This demonstration shows a reflection     |
  14.             |     technique known as 'Chrome Wrap'          |
  15.             |                                               |
  16.             |     100's - images/sprites                    |
  17.             |     200's - objects                           |
  18.             |                                               |
  19.             *-----------------------------------------------*
  20. remend
  21.  
  22. `------------------------------------------------------SETUP------------------------------------------------------
  23.  
  24. set display mode 800,600,16
  25. autocam off
  26. hide mouse
  27. sync on
  28. backdrop on
  29. color backdrop rgb(0,0,0)
  30. anglex# = -90.0
  31.  
  32. `-----------images
  33.  
  34. load image "map1.bmp",101
  35. load image "map2.bmp",102
  36. load image "text1.bmp", 106
  37.  
  38. `convert image to sprite to make it see-through
  39. sprite 1,0,0,106
  40.  
  41. `-----------models
  42.  
  43. `load in the same object twice
  44. load object "can.x",201
  45. load object "can.x",202
  46.  
  47. `position both objects in the same place
  48. position object 201,0,0,150
  49. position object 202,0,0,150
  50.  
  51. `scale one object slightly smaller than the other so that their textures don't interfere
  52. scale object 202, 99, 99, 99
  53.  
  54. `replace the texture of the 'larger' object with the reflection map and make it 'ghostly'
  55. texture object 201,101
  56. ghost object on 201
  57.  
  58. `----------------------------------------------------MAIN LOOP----------------------------------------------------
  59.  
  60. do
  61.    `get any mouse movements
  62.    anglex#=wrapvalue(anglex#-mousemovey())
  63.    angley#=wrapvalue(angley#-mousemovex())
  64.  
  65.    `rotate both objects at the same time
  66.    rotate object 201, anglex#, 0.0, angley#
  67.    rotate object 202, anglex#, 0.0, angley#
  68.  
  69.    `this is the funky bit - move the texture offset of the reflection map in the opposite
  70.    `direction as the mouse moves, thus keeping the texture facing the camera
  71.    `the current angle must be tested to counteract the texture scrolling the wrong way
  72.  
  73.    if anglex# > 180 & anglex# < 360
  74.       scroll object texture 201, (mousemovex()*0.00275), (mousemovey()*0.0055)
  75.    else
  76.       scroll object texture 201, (mousemovex()*0.00275), 0.0-(mousemovey()*0.0055)
  77.    endif
  78.          `                                         ^--------------------------^------- these numbers work for
  79.          `                                                                             any model/texture
  80.    `move camera in or out when mouse buttons pressed
  81.    if mouseclick()=1 then move camera 5
  82.    if mouseclick()=2 then move camera -5
  83.  
  84.    `change reflection map on keys '1' or '2'
  85.    if keystate(2) then texture object 201,101
  86.    if keystate(3) then texture object 201,102
  87.  
  88.    sync
  89. loop
  90.  
  91. `------------------------------------------------------END--------------------------------------------------------
  92.